package com.kamistoat.meimeimall.meimeimallgateway.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 排除掉common模块中对网关模块不兼容的Bean。
 * 例如 GlobalLoginInterceptor，它要求请求必须是非响应式Servlet，而网关是响应式Server，如果引入则会报错。
 */
@Component
public class RemoveNessBeanProcessor implements BeanDefinitionRegistryPostProcessor {
    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        registry.removeBeanDefinition("globalLoginInterceptor");
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    }
}
